package com.bankcomm.ui.specialwidget;

////#define Android1.5
//#ifdef Android1.5
//@import java.util.List;
//@
//@import android.app.Activity;
//@import android.content.Context;
//@import android.graphics.Bitmap;
//@import android.graphics.Canvas;
//@import android.graphics.Paint;
//@import android.graphics.Point;
//@import android.location.Location;
//@import android.location.LocationListener;
//@import android.location.LocationManager;
//@import android.os.Bundle;
//@
//@import com.google.android.maps.GeoPoint;
//@import com.google.android.maps.MapController;
//@import com.google.android.maps.MapView;
//@import com.google.android.maps.Overlay;
//@import com.rytong.tools.ui.Component;
//@import com.rytong.tools.ui.ImageRepository;
//@
//@/**
//@ * 该方法为google地图调用方法，外层界面参数必须为MapActivity
//@ * 
//@ * @author 谷歌地图
//@ */
//@public class LPMapView extends Component {
//@
//@	GeoPoint geoPoint;
//@	String latitude;
//@	String longitude;
//@	String title;
//@
//@	public class MyLPMapView extends MapView implements CompositedComponent {
//@
//@		public MyLPMapView(Context context) {
//@			super(context, "0N15LHkyQXD3syYmpe4OtQ_YIXDZPylAmu21Y4A");
//@			// TODO Auto-generated constructor stub
//@			// lightpole apikey
//@			// mapView = new MapView(this,
//@			// "0N15LHkyQXD2F84Bu2KXiRv0ODMq9Tu1UpxQkQg");
//@			setBuiltInZoomControls(true);
//@			displayZoomControls(true);
//@			setEnabled(true);
//@			setClickable(true);
//@		}
//@
//@		@Override
//@		public Component composited() {
//@			// TODO Auto-generated method stub
//@			return LPMapView.this;
//@		}
//@
//@	}
//@
//@	/**
//@	 * 
//@	 * @param mapType
//@	 *            地图类型，三种客户端：road(街道平面图)/satellite(卫星鸟瞰图)/other(带路况平面图或不带路标卫星鸟瞰图)
//@	 */
//@	protected void setMapType(String mapType) {
//@		MyLPMapView temp = (MyLPMapView) realView_;
//@		if (mapType.equalsIgnoreCase("road")) {
//@			temp.setStreetView(true);
//@		} else if (mapType.equalsIgnoreCase("satellite")) {
//@			temp.setSatellite(true);
//@		} else {
//@			temp.setTraffic(true);
//@		}
//@	}
//@
//@	/**
//@	 * 
//@	 * @param isEnabled
//@	 *            设置地图是否可以滚动（横竖方向一同设置）
//@	 */
//@	protected void setMapScrollEnabled(boolean isEnabled) {
//@		MyLPMapView temp = (MyLPMapView) realView_;
//@		temp.setHorizontalScrollBarEnabled(isEnabled);
//@		temp.setVerticalScrollBarEnabled(isEnabled);
//@	}
//@
//@	protected void setLocation() {
//@		MyLPMapView temp = (MyLPMapView) realView_;
//@		MapController mapController = getCotroller();
//@		Bundle extras = ((Activity) temp.getContext()).getIntent().getExtras();
//@		if (extras != null) {
//@			latitude = extras.getString("latitude");
//@			longitude = extras.getString("longitude");
//@			title = extras.getString("title");
//@			if (title == null)
//@				title = "位置";
//@
//@			Double lat = Double.parseDouble(latitude) * 1E6;
//@			Double lon = Double.parseDouble(longitude) * 1E6;
//@			geoPoint = new GeoPoint(lat.intValue(), lon.intValue());
//@			mapController.setCenter(geoPoint);
//@			mapController.setZoom(17);
//@			mapController.animateTo(geoPoint);
//@			postInvalidate();
//@
//@			MyLocationOverlay myLocationOverlay = new MyLocationOverlay();
//@			List<Overlay> list = temp.getOverlays();
//@			list.add(myLocationOverlay);
//@		}
//@
//@	}
//@
//@	private MapController getCotroller() {
//@		// TODO Auto-generated method stub
//@		MyLPMapView temp = (MyLPMapView) realView_;
//@		return temp.getController();
//@	}
//@
//@	protected boolean isRouteDisplayed() {
//@		return false;
//@	}
//@
//@	class MyLocationOverlay extends Overlay {
//@		@Override
//@		public boolean draw(Canvas canvas, MapView mapView, boolean shadow,
//@				long when) {
//@			super.draw(canvas, mapView, shadow, when);
//@			Paint paint = new Paint();
//@			paint.setAntiAlias(true);
//@			Point myScreenCoords = new Point();
//@			// 将经纬度转换成实际屏幕坐标
//@			mapView.getProjection().toPixels(geoPoint, myScreenCoords);
//@			paint.setStrokeWidth(1);
//@
//@			paint.setARGB(255, 255, 0, 0);
//@
//@			Bitmap bmp = ImageRepository.getImageFromAssetFile(getContext(),
//@					"map_red_pin.png");
//@
//@			canvas.drawBitmap(bmp, myScreenCoords.x, myScreenCoords.y, paint);
//@			canvas.drawText(title, myScreenCoords.x, myScreenCoords.y, paint);
//@
//@			return true;
//@		}
//@	}
//@
//@	public Context getContext() {
//@		// TODO Auto-generated method stub
//@		return realView_.getContext();
//@	}
//@
//@	/**
//@	 * 将获取的经纬值存入一个double数组中返回
//@	 * 
//@	 * @return
//@	 */
//@	public double[] getCurrentLocation() {
//@		final double[] latAndLon = new double[2];
//@		LocationManager locationManager = (LocationManager) getContext()
//@				.getSystemService(Context.LOCATION_SERVICE);
//@		if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)
//@				|| locationManager
//@						.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
//@			Location location = locationManager
//@					.getLastKnownLocation(LocationManager.GPS_PROVIDER);
//@			if (location != null) {
//@				latAndLon[0] = location.getLatitude();
//@				latAndLon[1] = location.getLongitude();
//@			}
//@			LocationListener locationListener = new LocationListener() {
//@				public void onLocationChanged(Location location) {
//@					// 当坐标改变时触发此函数，如果Provider传进相同的坐标，它就不会被触发
//@					if (location != null) {
//@						latAndLon[0] = location.getLatitude();
//@						latAndLon[1] = location.getLongitude();
//@					}
//@				}
//@
//@				public void onProviderDisabled(String provider) {
//@					// Provider被disable时触发此函数，比如GPS被关闭
//@				}
//@
//@				public void onProviderEnabled(String provider) {
//@					// Provider被enable时触发此函数，比如GPS被打开
//@				}
//@
//@				public void onStatusChanged(String provider, int status,
//@						Bundle extras) {
//@					// Provider的转态在可用、暂时不可用和无服务三个状态直接切换时触发此函数
//@				}
//@			};
//@			// LocationManager对象，用于监听Location更改时事件。
//@			locationManager.requestLocationUpdates(
//@					LocationManager.GPS_PROVIDER, 2000, 0, locationListener);
//@		}
//@		return latAndLon;
//@	}
//@
//@}
// #endif
